package ch.ethz.fcl.metrobuzz.algorithm.network;

import java.util.ArrayList;
import java.util.List;

import ch.ethz.fcl.metrobuzz.data.scene.basemap.Node;

/**
 * path of connecting nodes
 * 
 * @author ZengWei
 * 
 */
public class Path {
	// private List<Edge> edges;
	private List<Node> nodes;
	private float cost;

	public Path() {
		nodes = new ArrayList<Node>();
	}

	public Path(Path p) {
		nodes = new ArrayList<Node>();

		for (Node n : p.getPath())
			nodes.add(n);

		cost = p.getCost();
	}

	public void addPath(Node node, float cost) {
		nodes.add(node);
		this.cost += cost;
	}

	public void removePath(int start, int end) {
		for (int i = start; i < end; i++)
			nodes.remove(i);
	}

	public void setCost(float cost) {
		this.cost = cost;
	}

	public List<Node> getPath() {
		return nodes;
	}

	public int size() {
		return nodes.size();
	}

	public float getCost() {
		return cost;
	}

	@Override
	public String toString() {
		String output = "";
		int i = 0;
		for (; i < nodes.size() - 1; i++)
			output += (nodes.get(i).getId() + "->");
		output += (nodes.get(i).getId());
		return output;
	}
}
